package com.ugoodtech.mdcc.core.utils;

//import org.apache.http.HttpEntity;
//import org.apache.http.client.methods.HttpUriRequest;
//import org.apache.http.client.methods.RequestBuilder;
//import org.apache.http.client.protocol.HttpClientContext;
//import org.apache.http.impl.client.AbstractResponseHandler;
//import org.apache.http.util.EntityUtils;
//
//import java.io.*;
//import java.net.HttpURLConnection;
//import java.net.URL;
//import java.text.SimpleDateFormat;
//import java.util.Date;
//import java.util.HashMap;
//import java.util.Map;

import java.io.ByteArrayOutputStream;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2018/6/12 0012.
 */
public class Test {

//    public static void main(String[] args) throws Exception {
//        String templetPath = "E:\\ugood\\project\\vstar\\vstar_backend\\web\\src\\main\\webapp";
//        Map<String, Object> param = new HashMap<String, Object>();
//        param.put("{a1}", "测试1");
//        param.put("{a2}", "上海");
//        param.put("{a3}", "老发");
//        param.put("{a4}", "老白");
//        SimpleDateFormat in = new SimpleDateFormat("dd/MM/yyyy");
//        param.put("{a5}", in.format(new Date()));
//        param.put("101", "老白1");
//        param.put("102", "老白2");
//        param.put("103", "老白3");
//        param.put("104", "老白4");
//        param.put("105", "老白5");
//        param.put("106", "老白6");
//        param.put("107", "老白7");
//        param.put("108", "老白8");
//        param.put("234", "老白234");
//        param.put("01}", "老白01");
//        param.put("02}", "老白02");
//
//
//        URL url=new URL("http://vstar.oss-cn-hangzhou.aliyuncs.com/backend/photo/1534053126167_%E5%85%89%E4%BA%AE%E5%BA%A6.png");
//        HttpURLConnection con=(HttpURLConnection) url.openConnection();//打开链接方式
//        con.setRequestMethod("GET");//以GET方式请求连接
//        con.setConnectTimeout(5*1000);//设置连接时间为5秒
//        InputStream is=con.getInputStream();//输入流获取图片
//        byte[] byt=readInputStream(is);
//
//        Map<String,Object> header1 = new HashMap<String, Object>();
//        header1.put("width", 600);
//        header1.put("height", 400);
//        header1.put("type", "png");
//        header1.put("content", byt);
//        param.put("{03}",header1);
////        param.put("003", "老白003");
//
////        Map<String,Object> header = new HashMap<String, Object>();
////        header.put("width", 100);
////        header.put("height", 150);
////        header.put("type", "jpg");
////        header.put("content", WordUtil.inputStream2ByteArray(new FileInputStream("C:\\Users\\Administrator\\Desktop\\test.png"), true));
////        param.put("${header}",header);
////        ByteArrayOutputStream baossvg = new ByteArrayOutputStream();
////        WordUtil.convertToPng("<svg version='1.1' class='highcharts-root' style='font-family:&quot;Lucida Grande&quot;, &quot;Lucida Sans Unicode&quot;, Arial, Helvetica, sans-serif;font-size:12px;' xmlns='http://www.w3.org/2000/svg' width='634' height='400' viewBox='0 0 634 400'><desc>Created with Highcharts 6.1.1</desc><defs><clipPath id='highcharts-1pwty3v-21'><rect x='0' y='0' width='550' height='353' fill='none'></rect></clipPath></defs><rect fill='#ffffff' class='highcharts-background' x='0' y='0' width='634' height='400' rx='0' ry='0'></rect><rect fill='none' class='highcharts-plot-background' x='74' y='10' width='550' height='353'></rect><g class='highcharts-grid highcharts-xaxis-grid ' data-z-index='1'><path fill='none' data-z-index='1' class='highcharts-grid-line' d='M 348.5 10 L 348.5 363' opacity='1'></path><path fill='none' data-z-index='1' class='highcharts-grid-line' d='M 623.5 10 L 623.5 363' opacity='1'></path><path fill='none' data-z-index='1' class='highcharts-grid-line' d='M 73.5 10 L 73.5 363' opacity='1'></path></g><g class='highcharts-grid highcharts-yaxis-grid ' data-z-index='1'><path fill='none' stroke='#e6e6e6' stroke-width='1' data-z-index='1' class='highcharts-grid-line' d='M 74 363.5 L 624 363.5' opacity='1'></path><path fill='none' stroke='#e6e6e6' stroke-width='1' data-z-index='1' class='highcharts-grid-line' d='M 74 292.5 L 624 292.5' opacity='1'></path><path fill='none' stroke='#e6e6e6' stroke-width='1' data-z-index='1' class='highcharts-grid-line' d='M 74 222.5 L 624 222.5' opacity='1'></path><path fill='none' stroke='#e6e6e6' stroke-width='1' data-z-index='1' class='highcharts-grid-line' d='M 74 151.5 L 624 151.5' opacity='1'></path><path fill='none' stroke='#e6e6e6' stroke-width='1' data-z-index='1' class='highcharts-grid-line' d='M 74 81.5 L 624 81.5' opacity='1'></path><path fill='none' stroke='#e6e6e6' stroke-width='1' data-z-index='1' class='highcharts-grid-line' d='M 74 9.5 L 624 9.5' opacity='1'></path></g><rect fill='none' class='highcharts-plot-border' data-z-index='1' x='74' y='10' width='550' height='353'></rect><g class='highcharts-axis highcharts-xaxis ' data-z-index='2'><path fill='none' class='highcharts-tick' stroke='#ccd6eb' stroke-width='1' d='M 348.5 363 L 348.5 373' opacity='1'></path><path fill='none' class='highcharts-tick' stroke='#ccd6eb' stroke-width='1' d='M 624.5 363 L 624.5 373' opacity='1'></path><path fill='none' class='highcharts-tick' stroke='#ccd6eb' stroke-width='1' d='M 73.5 363 L 73.5 373' opacity='1'></path><path fill='none' class='highcharts-axis-line' stroke='#ccd6eb' stroke-width='1' data-z-index='7' d='M 74 363.5 L 624 363.5'></path></g><g class='highcharts-axis highcharts-yaxis ' data-z-index='2'><text x='26.09375' data-z-index='7' text-anchor='middle' transform='translate(0,0) rotate(270 26.09375 186.5)' class='highcharts-axis-title' style='color:#666666;fill:#666666;' y='186.5'><tspan>维修产值</tspan></text><path fill='none' class='highcharts-axis-line' data-z-index='7' d='M 74 10 L 74 363'></path></g><g class='highcharts-series-group' data-z-index='3'><g data-z-index='0.1' class='highcharts-series highcharts-series-0 highcharts-column-series highcharts-color-0 highcharts-tracker' transform='translate(74,10) scale(1 1)' clip-path='url(#highcharts-1pwty3v-21)'><rect x='122.5' y='28.5' width='30' height='325' fill='#7cb5ec' stroke='#ffffff' stroke-width='1' class='highcharts-point highcharts-color-0'></rect><rect x='397.5' y='28.5' width='30' height='325' fill='#7cb5ec' stroke='#ffffff' stroke-width='1' class='highcharts-point highcharts-color-0'></rect></g><g data-z-index='0.1' class='highcharts-markers highcharts-series-0 highcharts-column-series highcharts-color-0 ' transform='translate(74,10) scale(1 1)' clip-path='none'></g></g><text x='317' text-anchor='middle' class='highcharts-title' data-z-index='4' style='color:#333333;font-size:18px;fill:#333333;' y='24'></text><text x='317' text-anchor='middle' class='highcharts-subtitle' data-z-index='4' style='color:#666666;fill:#666666;' y='24'></text><g class='highcharts-axis-labels highcharts-xaxis-labels ' data-z-index='7'><text x='211.5' style='color:#666666;cursor:default;font-size:11px;fill:#666666;' text-anchor='middle' transform='translate(0,0)' y='382' opacity='1'>改善前1个月</text><text x='486.5' style='color:#666666;cursor:default;font-size:11px;fill:#666666;' text-anchor='middle' transform='translate(0,0)' y='382' opacity='1'>改善当月</text></g><g class='highcharts-axis-labels highcharts-yaxis-labels ' data-z-index='7'><text x='59' style='color:#666666;cursor:default;font-size:11px;fill:#666666;' text-anchor='end' transform='translate(0,0)' y='367' opacity='1'>0</text><text x='59' style='color:#666666;cursor:default;font-size:11px;fill:#666666;' text-anchor='end' transform='translate(0,0)' y='296' opacity='1'>50</text><text x='59' style='color:#666666;cursor:default;font-size:11px;fill:#666666;' text-anchor='end' transform='translate(0,0)' y='226' opacity='1'>100</text><text x='59' style='color:#666666;cursor:default;font-size:11px;fill:#666666;' text-anchor='end' transform='translate(0,0)' y='155' opacity='1'>150</text><text x='59' style='color:#666666;cursor:default;font-size:11px;fill:#666666;' text-anchor='end' transform='translate(0,0)' y='85' opacity='1'>200</text><text x='59' style='color:#666666;cursor:default;font-size:11px;fill:#666666;' text-anchor='end' transform='translate(0,0)' y='14' opacity='1'>250</text></g></svg>", baossvg);
////        Map<String,Object> header = new HashMap<String, Object>();
////        header.put("width", 400);
////        header.put("height", 300);
////        header.put("type", "png");
////        header.put("content", baossvg.toByteArray());
////        param.put("04}",header);
////
//        String filePath = templetPath + "\\export\\kpi20180812.docx";
//        CustomXWPFDocument doc = WordUtil.generateWord(param, templetPath + "\\templet\\LeanPaintReport11.docx");
//        FileOutputStream fopts = new FileOutputStream(filePath);
//        doc.write(fopts);
//        fopts.close();
//        String[][] aaa = {{"1","张三"},{"2","李四"},{"3","王五"}};
//        ExportWordUtil.exportSTToWord(null,aaa,filePath);
//    }
//
////    public static byte[] get(String url) throws IOException {
////        HttpUriRequest httpUriRequest = RequestBuilder.get().setUri(url).build();
////        return httpClient.execute(httpUriRequest, new AbstractResponseHandler<byte[]>() {
////            @Override
////            public byte[] handleEntity(HttpEntity entity) throws IOException {
////                return EntityUtils.toByteArray(entity);
////            }
////        }, HttpClientContext.create());
////    }
//
//    public static byte[] readInputStream(InputStream is) throws Exception{
//        ByteArrayOutputStream outsream=new ByteArrayOutputStream();//创建一个字节数组输出流
//        byte []b=new byte[10240000];//创建byte数组并设置大小
//        int len=0;//设置图片起点存储位置
//        while((len=is.read(b))!=-1){//输入流读取图片未读取结束
//            outsream.write(b, 0, len);//边读写入b字节数组中
//        }
//        outsream.close();
//        return outsream.toByteArray();//返回字节数组
//    }
}